package com.grgbanking.it.wx.common.creator;

import com.grgbanking.it.external.component.ExtenalConstant;
import com.grgbanking.it.project.component.WXProjectConstant;
import com.grgbanking.it.wx.aes.AesException;
import com.grgbanking.it.wx.aes.WXBizMsgCrypt;
import com.grgbanking.it.wx.common.WXConstant;

/**
 * WXBizMsgCrypt工厂
 * 
 * WXBizMsgCryptFactory
 * 
 * @author 潘广伟
 * @Email p_3er@qq.com
 * @Date 2015-1-7 下午1:16:28
 * 
 * @version 1.0.0
 *
 */
public class WXBizMsgCryptFactory {
	
	public static WXBizMsgCrypt repairCrypt = null;
	public static WXBizMsgCrypt dailyCrypt = null;
	public static WXBizMsgCrypt supplierCrypt = null;
	
	
	
	public static WXBizMsgCrypt getRepairCrypt() throws AesException {
		if(repairCrypt == null){
			repairCrypt = new WXBizMsgCrypt(WXProjectConstant.OPERATION_CALLBACK_TOKEN, WXProjectConstant.OPERATION_CALLBACK_AESKEY, WXConstant.CORPID);
		}
		return repairCrypt;
	}



	public static WXBizMsgCrypt getDailyCrypt() {
		return dailyCrypt;
	}



	public static WXBizMsgCrypt getSupplierCrypt() throws AesException {
		if(supplierCrypt == null){
			supplierCrypt = new WXBizMsgCrypt(ExtenalConstant.SUPPLIER_CALLBACK_TOKEN, ExtenalConstant.SUPPLIER_CALLBACK_AESKEY, WXConstant.CORPID);
		}
		return supplierCrypt;
	}



	/**
	 * 获取编译器
	 * getCrypt
	 * 
	 * @param appId
	 * @return
	 * @throws AesException 
	 * @exception 
	 * @since  1.0.0
	 */
	public static WXBizMsgCrypt getCrypt(Integer appId) throws AesException{
		WXBizMsgCrypt crypt = null;
		if(appId == WXProjectConstant.REPAIR_AGENT_ID){
			crypt = getRepairCrypt();
		}else if(appId == ExtenalConstant.SUPPLIER_AGENT_ID){
			crypt = getSupplierCrypt();
		}
		
		return crypt;
	}
}
